﻿#region Copyright Statement
//////////////////////////////////////////////
//                                          //
//      Created By:   Ali Ghomi             //
//      Date:         21 Jan 2010           //
//////////////////////////////////////////////
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ORMAC.Attributes
{
    /// <summary>
    /// attribute class to help mapping between xml nodes and classes/properties
    /// each xml element (with attributes) maybe converted to a table in dataset and the table may be converted to a class using table attribute
    /// </summary>
    [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
    public class TableAttribute:BaseAttribute
    {

        private string m_TableName;
        /// <summary>
        /// Table Name
        /// </summary>
        public string TableName
        {
            get
            {
                return m_TableName;
            }
        }
        private string m_IntermediateTable1;
        /// <summary>
        /// Intermediate table name
        /// used when tha mapping should be carried out using more than one related tables
        /// </summary>
        public string IntermediateTable1
        {
            get
            {
                return m_IntermediateTable1;
            }
            set
            {
                m_IntermediateTable1 = value;
            }
        }
        private string m_Criteria;
        /// <summary>
        /// Criteria used for selecting items from a table
        /// </summary>
        public string Criteria
        {
            get
            {
                return m_Criteria;
            }
            set
            {
                m_Criteria = value;
            }
        }
        private bool m_usePrefix;
        /// <summary>
        /// column used to join parent table to child table
        /// </summary>
        public string ParentCol
        {
            get
            {
                return m_ParentCol;
            }
            set
            {
                m_ParentCol = value;
            }
        }

        private string  m_ParentCol;
        /// <summary>
        /// column used to join parent table to child table
        /// </summary>
        public string ChildCol
        {
            get
            {
                return m_ChildCol;
            }
            set
            {
                m_ChildCol = value;
            }
        }

        private string m_ChildCol;
        /// <summary>
        /// specifies if this property or class should use the prefix attribute from the aggregator class
        /// </summary>
        public bool UsePrefix
        {
            get
            {
                return m_usePrefix;
            }
            set
            {
                m_usePrefix = value;
            }
        }

        public TableAttribute(string schema, string tableName)
        {
            m_Schema = schema;
            m_TableName = tableName;
        }
        public TableAttribute(string schema, string tableName, string intermediateTable1):this(schema,tableName)
        {
            m_IntermediateTable1 = intermediateTable1;
        }
        public TableAttribute(string tableName):this("",tableName)
        {
        }

    }
}
